package com.proj.service.impl;

import com.proj.bean.Category;
import com.proj.bean.Goods;
import com.proj.bean.Goodsimg;
import com.proj.bean.Review;
import com.proj.dao.GoodsDao;
import com.proj.service.IGoodsService;
import com.proj.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class GoodsServiceImpl implements IGoodsService {

    @Autowired
    GoodsDao goodsDao;

    @Override
    public int add(Goods goods) {
        return goodsDao.add(goods);
    }

    @Override
    public int del(int id) {
        return goodsDao.del(id);
    }

    @Override
    public int edit(Goods goods) {
        return goodsDao.edit(goods);
    }

    @Override
    public Goods getById(int id) {
        return goodsDao.getById(id);
    }

    @Override
    public List<Goods> getList(Page page, String text) {
        return goodsDao.getList(page, text);
    }

    @Override
    public List<Goodsimg> getImgByGoodsid(int goodsid) {
        return goodsDao.getImgByGoodsid(goodsid);
    }

    @Override
    public int insertImg(int goodsid, String imgurl) {
        return goodsDao.insertImg(goodsid, imgurl);
    }

    @Override
    public int delImgById(int id) {
        return goodsDao.delImgById(id);
    }

    @Override
    public List<Goods> goodsList(Integer categoryid, String keywords) {
        return goodsDao.goodsList(categoryid, keywords);
    }

    @Override
    public List<Category> getParent(int category_id) {
        return goodsDao.getParent(category_id);
    }

    @Override
    public int getCount(String text) {
        return goodsDao.getCount(text);
    }

    @Override
    public List<Review> reviewlist(int goodsid) {
        return goodsDao.reviewlist(goodsid);
    }

    @Override
    public List<Goodsimg> getimg(int goodsid) {
        return goodsDao.getimg(goodsid);
    }

    @Override
    public int addsingletocart(int userid, int goodsid, int number) {
        return goodsDao.addsingletocart(userid, goodsid, number);
    }

    @Override
    public int ifbought(int userid, int goodsid) {
        return goodsDao.ifbought(userid, goodsid);
    }

    @Override
    public int newreview(Review review) {
        return goodsDao.newreview(review);
    }

    @Override
    public List<Review> getReviewByUserid(int userid) {
        return goodsDao.getReviewByUserid(userid);
    }

    @Override
    public int delReviewById(int id) {
        return goodsDao.delReviewById(id);
    }
}
